from pyramid.config import Configurator
from bbkb.resources import Root

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(root_factory=Root, settings=settings)
    config.add_static_view('static', 'bbkb:static', cache_max_age=3600)
    config.add_static_view('data', 'bbkb:data', cache_max_age=3600)
    
    # Add Routes
    config.add_route('index_view', '/')
    config.add_route('legacy_view', '/legacy')
    
    config.add_route('debugkb_loadtable_view', '/load_table')
    config.add_route('reconstitute_view', '/reconstitute')
    config.add_route('query_view', '/query')
    config.add_route('fact_frequency_view', '/factfrequency')

    config.add_route('mturk_index_view', '/mturk')
    config.add_route('mturk_retrieve_view', '/mturk_survey')
    
    # load any declarative resources and configuration
    config.scan()
    return config.make_wsgi_app()
